/*
 * Copyright (C) 2012 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * This code is not supported by Google
 *
 */

package com.google.enterprise.gsa.commerce;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class Product {

	private HashMap<String,List<String>> attributes;
	private String id, title, link, image_link, description;
	private float price;
	
	public Product() {
		attributes = new HashMap<String,List<String>>();
	}
	
	public String getID() {
		return this.id;
	}	
	
	public String getTitle() {
		return this.title;
	}

	public float getPrice() {
		return this.price;
	}
	
	public void setLink(String link) {
		this.link = link;
	}
	
	public String getLink() {
		return this.link;
	}
	
	public String getImageLink() {
		return this.image_link;
	}	
	
	public String getDescription() {
		return this.description;
	}	
		
	public List<String> getAttribute(String name){
		return this.attributes.get(name);
	}
	
	public void addAttribute(String name, String value) {
        if (name.equals("id"))
        	this.id = value;	
        else if (name.equals("title"))
        	this.title = value;
        else if (name.equals("image_link"))
        	this.image_link = value;           
        else if (name.equals("price"))  
        	this.price = Float.parseFloat(value);
        else if (name.equals("description"))  
        	this.description = value;

		List<String> curr = attributes.get(name);
		if (curr == null)
			curr = new ArrayList<String>();
		curr.add(value);
		this.attributes.put(name,curr);
	}
}
